package com.neuedu.yyzx.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.po.Customer;
import com.neuedu.yyzx.dto.CustomerNurseSetDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface CustomerMapper extends BaseMapper<Customer> {

    @Select({
            "<script>",
            "SELECT c.*, u.nickname, nl.level_name ",
            "FROM customer c ",
            "LEFT JOIN user u ON c.user_id = u.id ",
            "LEFT JOIN nurselevel nl ON c.level_id = nl.id ",
            "<where>",
            "  <if test='ew != null and ew.sqlSegment != null'>",
            "    ${ew.sqlSegment}",
            "  </if>",
            "</where>",
            "</script>"
    })
    IPage<CustomerNurseSetDTO> pageWithDetails(@Param("page") Page<CustomerNurseSetDTO> page, @Param("ew") LambdaQueryWrapper<Customer> queryWrapper);
}

